
#include "SQLNumberExpr.h"
#include "../../../sql/visitor/SQLASTVisitor.h"

SETCALSS(SQLNumberExpr);

SQLNumberExpr::SQLNumberExpr()
{
}
SQLNumberExpr::~SQLNumberExpr()
{
  // if (number != NULL)
  // {
  // 	// delete number;
  // 	// number = NULL;
  // }
}
SQLNumberExpr::SQLNumberExpr(double theNumber)
{

  number = theNumber;
}

double SQLNumberExpr::getNumber()
{
  return number;
}

void SQLNumberExpr::setNumber(double theNumber)
{
  number = theNumber;
}

void SQLNumberExpr::output(std::stringstream *buf)
{
  if (chars != NULL)
  {
    *buf << chars;
  }
  else
  {
    *buf << this->number;
  }
}

void SQLNumberExpr::accept0(SQLASTVisitor_ptr visitor)
{
  visitor->visit(SharedObject(SQLNumberExpr));
  visitor->endVisit(SharedObject(SQLNumberExpr));
}

// int SQLNumberExpr::hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((number == null) ? 0 : number.hashCode());
// return result;
//}

// BOOL_ptr SQLNumberExpr::equals(Object obj) {
// if (this == obj) {
// return BOOL::TRUE;
//}
// if (obj == null) {
// return BOOL::FALSE;
//}
// if (getClass() != obj.getClass()) {
// return BOOL::FALSE;
//}
// SQLNumberExpr other = (SQLNumberExpr) obj;
// if (number == null) {
// if (other.number != null) {
// return BOOL::FALSE;
//}
//} else if (!number.equals(other.number)) {
// return BOOL::FALSE;
//}
// return BOOL::TRUE;
//}

string_ptr SQLNumberExpr::getLiteral()
{
  if (chars == NULL)
  {
    return make_string_ptr("");
  }

  return make_string_ptr(chars);
}

SQLObject_ptr SQLNumberExpr::clone()
{
  SQLObject_ptr clone_tmp = SQLNumberExpr_ptr(new SQLNumberExpr());
  SQLNumberExpr_ptr x = std::dynamic_pointer_cast<SQLNumberExpr>(clone_tmp);
  // SQLNumberExpr *x = new SQLNumberExpr();
  x->chars = chars;
  x->number = number;
  return x;
}
